package com.xh.shuati.ai.chatmemory;


import dev.langchain4j.memory.chat.ChatMemoryProvider;
import dev.langchain4j.memory.chat.MessageWindowChatMemory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

@Configuration
public class ChatMemoryProviderConfig {


    @Resource
    private MySqlBasedChatMemory mySqlBasedChatMemory;
    @Resource
    private MongodbBasedChatMemoryStore mongodbBasedChatMemoryStore;

    @Bean
    public ChatMemoryProvider mySqlBasedChatMemoryProvder() {
        return  memoryId -> MessageWindowChatMemory.builder()
                .id(memoryId)
                .maxMessages(15)
//                .chatMemoryStore(mySqlBasedChatMemory)
                .chatMemoryStore(mongodbBasedChatMemoryStore)
                .build();
    }
}
